<?php
function show($status,$message,$data=array()){
    $result = array(
        "status"=>$status,
        "message"=>$message,
        "data"=>$data,
    );
    //return $result;
    exit(json_encode($result));
}
//
function getMd5Password($pwd){
    return MD5($pwd.C('MD5_PRE'));
}
function getMenuType($type){
    return $type==1 ? "后台菜单":"前台导航";
}
function status($status){
  if($status==0){
      $str="关闭";
  }elseif($status==1){
      $str="正常";
  }elseif($status==-1){
      $str="删除";
  }
  return $str;
}
function getMenuUrl($nav){
    $url='/admin.php?c='.$nav['c'].'&a='.$nav['f'];
    if($nav['f']=='index'){
       $url='/admin.php?c='.$nav['c']; 
    }
    return $url;
}
function getActive($navc){
  $c=strtolower(CONTROLLER_NAME);
  if(strtolower($navc)==$c){
      return 'class="active"';
  }
   return '';    
}
function showkind($status,$data){
  header('content-type:application/json;charset="UTF-8"');//转码
  //判断
  if($status==0){
      exit(json_encode(array("error"=>0,'url'=>$data)));
  }
   exit(json_encode(array("error"=>1,'message'=>"上传失败")));
    
}
function getLoginUsername(){
    return $_SESSION['adminUser']['username'] ? $_SESSION['adminUser']['username'] :'';
}
function getCatName($navs,$id){
    foreach($navs as $nav){
      $navList[$nav['menu_id']]=$nav['name']; 
    }
    return  isset($navList[$id]) ? $navList[$id] :'';
    
}
function getCopyFromById($id){
     $copyFrom=C("COPY_FROM");
     return $copyFrom[$id] ? $copyFrom[$id] :"";
}
function isThumb($thumb){
    if($thumb){
       return '<span style="color:red">有</span>'; 
    }
    return '<span style="color:blue">无</span>';
}



